<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <style>
    div {
      margin-top: 20px;
      float: left;
    flex: auto;
  grid-template-columns: auto;}
  </style>

</body>
<script>
  function max(a, b) {
    //三元运算符  
    return a > b ? a : b;
  }
  a = prompt("请输入第一个数字："); // 1
  b = prompt("请输入第二个数字："); // 2
  console.log(max(a, b)); // 2
  //求任意数组的最大值
  function maxArray(arr) {
    //先准备一个max变量
    let max = arr[0];
    for (let i = 1; i < arr.length; i++) {
      if (arr[i] > max) {
        max = arr[i]
      }
    }
    return max;    
  }
  console.log(maxArray([1, 2, 3, 4, 5])); // 532
</script>

</html>